<html>
<head>
<script type="text/javascript">
var aJaxURL 		= "server-side/reserves/cartrije_reserve1.action.php";						//server side folder url
var tName			= "example-1";														//table name
var fname			= "add-edit-form";													//form name
    	
$(document).ready(function () {      

		
	LoadTable();
		
	//SetEvents("", "", "", tName, fName , aJaxURL);
	
});

function LoadTable(){
	
	/* Table ID, aJaxURL, Action, Colum Number, Custom Request, Hidden Colum */
	GetDataTable("example-1", aJaxURL, "get_cartridge_type_list", 5, "", 0);
	GetDataTable("example-2", aJaxURL, "get_working_cartridge_list", 5, "", 0);
	GetDataTable("example-3", aJaxURL, "get_disworking_cartridge_list", 5, "", 0);

	$("#example-1 tbody").on("click", "tr", function () {
        var nTds = $("td", this);
        var empty = $(nTds[0]).attr("class");

        if (empty != "dataTables_empty") {
            var rID = $(nTds[0]).text();
            
        	GetDataTable("example-2", aJaxURL, "get_working_cartridge_list", 5, "id="+rID, 0);
        	GetDataTable("example-3", aJaxURL, "get_disworking_cartridge_list", 5, "id="+rID, 0); 
        }
    });


    $("#example-2 tbody").on("click", "tr", function () {
        var nTds = $("td", this);
        var empty = $(nTds[0]).attr("class");

        if (empty != "dataTables_empty") {
            var rID = $(nTds[0]).text();

            $.ajax({
                url: aJaxURL,
                type: "POST",
                data: "act=get_edit_page&id=" + rID,
                dataType: "json",
                success: function (data) {
                    if (typeof (data.error) != "undefined") {
                        if (data.error != "") {
                            alert(data.error);
                        } else {
                            $("#" + fname).html(data.page);
                            LoadDialog();
                        }
                    }
                }
            });
        }
    });

    $("#example-3 tbody").on("click", "tr", function () {
        var nTds = $("td", this);
        var empty = $(nTds[0]).attr("class");

        if (empty != "dataTables_empty") {
            var rID = $(nTds[0]).text();

            $.ajax({
                url: aJaxURL,
                type: "POST",
                data: "act=get_edit_page&id=" + rID,
                dataType: "json",
                success: function (data) {
                    if (typeof (data.error) != "undefined") {
                        if (data.error != "") {
                            alert(data.error);
                        } else {
                            $("#" + fname).html(data.page);
                            LoadDialog();
                        }
                    }
                }
            });
        }
    });
}
		
function LoadDialog(){
			var buttons = {				
		        "cancel": {
	                text: "დახურვა",
	                id: "cancel-dialog",
	                click: function () {
	                	$(this).dialog("close");
	                }
	            }					
			};
			GetDialog(fname, 420, "auto", buttons);
}
</script>
</head>

<body>
	<table id="main-table">
		<tr>
			<td>			
			    <div id="dt_example" class="ex_highlight_row">
			        <div id="container" style="width: 370px;">
			            <div id="dynamic" style="overflow-x: none !important;">
			            	<h2 class="left">კატრიჯები</h2>
			                <table class="display" id="example-1" style="width: 370px;">
			                    <thead>
			                        <tr id="datatable_header">
			                            <th>ID</th>
			                            <th style="width: 199px">მოდელი</th>
			                            <th style="width: 168px">რაოდენობა</th>
			                        </tr>
			                    </thead>
			                    <thead>
			                        <tr class="search_header">
			                            <th class="colum_hidden">
			                            	<input type="text" name="search_id1" value="ფილტრი" class="search_init" />
			                            </th>
			                            <th>
			                                <input type="text" name="search_model1" value="ფილტრი" class="search_init" />
			                            </th>
			                            <th>
			                                <input type="text" name="search_quantity1" value="ფილტრი" class="search_init" />
			                            </th>
			                        </tr>
			                    </thead>			                    
			                </table>
		                </div>	                
		            </div>
			    </div>			
			</td>
			
			<td>

            <div style="margin: 2px;">
            </div>				
			
			</td>
			
			<td>		
			    <div id="dt_example" class="ex_highlight_row">
			        <div id="container" style="width: 400px;">
			            <div id="dynamic" style="overflow-x: none !important;">
			            	<h2 class="left">დასამუხტი  კატრიჯები</h2>
			                <table class="display" id="example-2" style="width: 400px;">
			                    <thead>
			                        <tr id="datatable_header">
			                            <th>ID</th>
			                            <th style="width: 70px;">ბარათი</th>			                            
			                            <th style="width: 115px">მოდელი</th>
			                            <th style="width: 100%">შტრიხკოდი</th>
			                            
			                        </tr>
			                    </thead>
			                    <thead>
			                        <tr class="search_header">
			                            <th class="colum_hidden">
			                            	<input type="text" name="search_id1" value="ფილტრი" class="search_init" />
			                            </th>
			                            <th>
			                                <input type="text" name="search_model2" value="ფილტრი" class="search_init" />
			                            </th>
			                            <th>
			                                <input type="text" name="search_barcode2" value="ფილტრი" class="search_init" />
			                            </th>
			                            <th>
			                                <input type="text" name="search_barcode2" value="ფილტრი" class="search_init" />
			                            </th>

			                        </tr>
			                    </thead>			                    
			                </table>
		                </div>	                
		            </div>
			    </div>
			</td>
			<td>

            <div style="margin: 2px;">
            </div>				
			
			</td>
			<td>		
			    <div id="dt_example" class="ex_highlight_row">
			        <div id="container" style="width: 400px;">
			            <div id="dynamic">
			            	<h2 class="left">დამუხტული კატრიჯები</h2>
			                <table class="display" id="example-3" style="width: 400px;">
			                    <thead>
			                        <tr id="datatable_header">
			                            <th>ID</th>
			                            <th style="width: 70px;">ბარათი</th>			                            
			                            <th style="width: 115px">მოდელი</th>
			                            <th style="width: 100%">შტრიხკოდი</th>
			                        </tr>
			                    </thead>
			                    <thead>
			                        <tr class="search_header">
			                            <th class="colum_hidden">
			                            	<input type="text" name="search_id3" value="ფილტრი" class="search_init" />
			                            </th>
			                            <th>
			                                <input type="text" name="search_model3" value="ფილტრი" class="search_init" />
			                            </th>
			                            <th>
			                                <input type="text" name="search_barcode3" value="ფილტრი" class="search_init" />
			                            </th>
			                            <th>
			                                <input type="text" name="search_barcode3" value="ფილტრი" class="search_init" />
			                            </th>
			                        </tr>
			                    </thead>			                    
			                </table>
			            </div>
			        </div>
			    </div>
			</td>
			
		</tr>
	</table>
	<div id="add-edit-form" class="form-dialog" title="ინვოისი">
    	<!-- aJax -->
	</div>			
</body>
</html>